package jdbc;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;

public class Text {
    public static void main(String[] args) {
        UserInfo userInfo = InputUtil.getInputObject(new UserInfo(),"欢迎注册","删除");
        System.out.println(userInfo);
        try(
                Connection connection = DBUtill.getConnection()
        ) {
            System.out.println("与数据库家里来凝结");
            Statement statement = connection.createStatement();
//            Scanner c = new Scanner(System.in);
//            System.out.println("请输入用户名");
//            String username = c.nextLine();
//
            String sql = "DELETE FROM userinfo" + " WHERE username = '" + userInfo.getUsername() + "'";
            System.out.println(sql);
            int num = statement.executeUpdate(sql);
            if (num > 0) {
                System.out.println("删除成功");
            } else {
                System.out.println("删除失败");
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
